#pragma once

namespace Melting
{
	/// Macro used in classes unit tests
	#define UTEST( expression ) 		if( !(expression ) )			{	LOG("- TEST FAILED : "#expression"\n" ); bTestSuccess = false; } 
	#define UTEST_START					bool bTestSuccess = true;
	#define UTEST_RESULT				bTestSuccess


	/**
		Lightweight framework used to register unit tests, and the process them all 


		How to use it :

		//--------------------------------------------------------------------------------------------
		// 1. create a function matching the TestFuncPtr prototype, and inside use the 3 UTESTxxx MACROs like this

		bool ExampleSIMDUnitTest( void )
		{
			LOG("::::::::: Functions : SIMD ::::::::::\n");

			// init the UTEST stuff
			UTEST_START;

			// logging won't kill you
			LOG("-- Load(  ) && Store( )  \n");
			{
				Vec3 vOriginal( 0, 1, 2 );
				SIMDVector input;

				SIMD_LOAD_A_FLOAT3( vOriginal, input ); 


				Vec3 vResult;
				
				SIMD_STORE_A_FLOAT3( vResult, input ); 
				
				// actual piece of testing
				UTEST( vResult == vOriginal );					
			}

			return UTEST_RESULT;
		}

		//--------------------------------------------------------------------------------------------
		// 2. in your main() function, at startup (e.g.)

		// register some test functions
		UnitTest::RegisterTest( ExampleSIMDUnitTest );
		UnitTest::RegisterTest( Cone::UnitTest );
		UnitTest::RegisterTest( AABBox::UnitTest );

		// process all registered tests, and abort with assert on the first error
		UnitTest::ProcessAllTests( true );

		UnitTest::RemoveAllTests();
	*/ 
	namespace UnitTest
	{ 
		/// Prototype for unit test registerable function pointer
		typedef bool (*TestFuncPtr)( void );


		/// Register a Unit Test as a pointer to function 		
		void RegisterTest( TestFuncPtr pfuncTest );
		
		/// Remove all tests, processed or not
		void RemoveAllTests( void );

		/// Process all registered tests, and eventually AbortOnError
		void ProcessAllTests( bool bAbortOnError );
	
	}; 
}
